<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var name=1;
        function test(){
            var name=2;
            console.log(this.name); // 1
            return function inner(){
                console.log(name);// 2
            }
        }
        test();
        test()();
        var b={
            name:3
        }
        b.test=test;
        b.test();// 3
        var c=b.test;
        c(); // 1
        new test();// undefined
    </script>
</body>
</html>